<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8" %>
<%@ include file="/cms/include/init_admin.jsp" %>
<%@ page import="com.qbooks.board.*" %>
<%

	String board_id			= StringUtil.nvl(request.getParameter("board_id"), "4");
	String search_col		= StringUtil.nvl(request.getParameter("search_col"), "subject");
	String search_word		= StringUtil.nvl(request.getParameter("search_word"));
	String curr_page 		= StringUtil.nvl(request.getParameter("curr_page"), "1");
	
	String search_url		= "./wordList.jsp?board_id="+board_id+"&search_col="+search_col+"&search_word="+search_word;
	
	BoardDAO boardDAO 		= new BoardDAO();
	
	HashMap infos = new HashMap();
	infos.put("board_id",		board_id);
	
	HashList boardInfo		= boardDAO.selectBoardInfo(infos);
	
	infos.put("search_col",		search_col);
	infos.put("search_word",	search_word);
	infos.put("curr_page",		curr_page);
	infos.put("line_per_page",	boardInfo.get("line_per_page",0));
	
	HashList wordList 		= boardDAO.selectWordList(infos);
	
	//쓰기권한
	boolean bWritable		= true;
	

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<title><%= SYSTEM_NAME %></title>
	<%@ include file="/cms/include/cssnjs.jsp"  %>
	<script type="text/javascript">
	$(document).ready(function() {
		$('#s_name').focus().select();
		$('#list').find('tr').hover(
				function () { $(this).addClass("hover"); }
			  , function () { $(this).removeClass("hover"); }
			)
			.click(function(){
				//$('#asingono').val($(this).find('input:hidden[name=asingono]').val());
				//$('#searchForm').attr('action', './salesDetail.do');
				//$('#searchForm').submit();
			});
	});



	function fnWordDetail(board_id) {
		cfOpen('/board/wordWrite.jsp?board_id='+board_id, '게시판', 900, 600);
	}
	
	
	function fnWordView(word_id) {
		cfOpen('/board/wordView.jsp?word_id=' + word_id + '&board_id=<%=board_id %>&search_col=<%=search_col%>&search_word=<%=search_word%>&curr_page=<%=curr_page%>', '게시판', 900, 600);
	}
	

	</script>
</head>
<body>
<div id="wrap">
	<div id="top">
		<%@ include file="/cms/include/top.jsp" %>
	</div>
	<div id="page">
		<div id="menu">
			<%@ include file="/cms/include/leftMenu.jsp" %>
		</div>
		<div id="contents">
			<div class="menu_title">
				<h1><%= boardInfo.get("board_name",0) %></h1>
				<p>CMS > 업무공유 > <b>업무게시판</b></p>
			</div>
			<div class="clear line_01"></div>

			<table width="100%" border="0" cellspacing="0" cellpadding="0" class="table_03">
        <colgroup>
					<col width="100px"/>
					<col />
					<col width="60px"/>
					<col width="60px"/>
					<col width="60px"/>
				</colgroup>
				<thead>
                    <tr>
	                    <th><p>No</p></th>
	                    <th><p>제목</p></th>
	                    <th><p>작성자</p></th>
	                    <th><p>조회수</p></th>
	                    <th><p>작성일</p></th>
	                </tr>
	            </thead>
	            <tbody>
       <%
         String prevWordNum = "";
         for (int i = 0; i < wordList.size(); i++) {

       %>
                      <tr>
                        <td  align="center" valign="middle">
                        <%			if (prevWordNum.equals(wordList.get("word_num",i))) {	%>
										&nbsp;
						<%			} else {	%>
										<%= wordList.get("word_num",i) %>
						<%			}	%>
                        </td>
                        <td valign="middle" class="board_txt">
		<%			if (wordList.getInt("depth",i)> 0)
				 	{
		%>			 		<span style="padding-left:<%= 10 * (wordList.getInt("depth",i)-1) %>px">&nbsp;</span>
							<img src="/img/icon/ico_re_i.gif"/>
		<%			}	%>
                        <a href="#nohref" onclick="fnWordView('<%=wordList.get("word_id",i)%>')"><%= StringUtil.substring(wordList.get("subject",i),34) %></a></td>
                        <td width="100" align="center" valign="middle"><%= wordList.get("author_name",i) %></td>
                        <td width="100" align="center" valign="middle"><%= wordList.get("count",i) %></td>
                        <td width="100" align="center" valign="middle"><%= wordList.get("init_date",i) %></td>
                      </tr>
   <%
       	prevWordNum = wordList.get("word_num",i);
         } %>
         				</tbody>
                    </table>


<%	if (bWritable) {	%>
    	<div style="text-align:right">
			<a href="#nohref" onclick="fnWordDetail(<%= board_id %>)">글쓰기</a>
		</div>
<%	}	%>

		<!-- 검색조건 -->
        <div style="text-align:center">
           	<form name="searchForm" method="post" action="./wordList.jsp">
        		<input type="hidden" name="board_id" value="<%= board_id %>"/>
	            <select name="search_col" style="width:80px;">
	              <option value="subject" <%= StringUtil.selected("subject", search_col) %>>제목</option>
	              <option value="content" <%= StringUtil.selected("content", search_word) %>>내용</option>
	              <option value="author_name" <%= StringUtil.selected("author_name", search_word) %>>글쓴이</option>
	            </select>
				<input type="text" name="search_word" size="5" style="width:160px;" value="<%= search_word %>" />
				<input type="image" value="찾기" />
			</form>
        </div>

		<div class="pageNavi">
			<%= boardDAO.getPageHtml(infos, search_url) %>
		</div>
		</div>
	</div>
</div>
</body>
</html>
